********************************************************************************
** 	TITLE: e22_prob_ignite_ym_booked.do

**	PROJECT: IGNITE
** 
**  PURPOSE: Appendix Figure XXII: Probability of Exposed to IGNITE
********************************************************************************
		set sortseed 13

use "$output_data/prediction.dta", clear
keep if booking_date>=date("01/01/2016","MDY")

***** Probability of exposed to IGNITE as a function of month booked
		//stay ignite_0 for Recidivism
				cap drop stay
				gen stay = stay_rec
				cap drop ignite_0
				gen ignite_0 = ignite_0_rec
preserve 

keep if genesee

gen pr_ignite = ignite_0>0|booking_date>date("09/08/2020","MDY")

reg pr_ignite i.ym_booked if return_3m>=0&genesee
margins ym_booked, nose

mat M=r(table)'
mat li M
restore

preserve

svmat M
keep M1 
keep if !mi(M1)
gen ym_booked = 671+_n

set obs `=_N+2'
replace ym_booked = 719.5 if _n==_N-1
replace ym_booked =  727.5 if _n==_N

gen shade_max = 1.05 if _n>=_N-1
gen shade_min = -.05 if _n>=_N-1

tw ///
	(connected M1 ym_booked, ///
		lc(black) mc(black) msize(*.5) msymbol(Oh)) ///
	, ///
	xlab(672(12)756, format(%tm) labsize(*.75)) ///
	xscale(range(670 758)) legend(off) ///
	xtitle("Booking month") xline(728, lwidth(*2) lc(gs8) lp(solid)) ///
	ytitle("Share exposed to IGNITE") ///
	yscale(range(-.05 1.05) titlegap(-0)) aspect(.6) ///
	text(.98 718.5 "Start of IGNITE", size(*.85))


gr export "$figures/prob_ignite_ym_booked.pdf", replace
